package cate.game.pvp.pointrace.data;

import cate.game.rank.po.Rank;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Data
@Document(collection = "point-race-rank")
public class PointRaceRank extends Rank {
    public static final String INDEX_NAME = "INDEX";

    @Id
    private String uid;

    public static PointRaceRank of(PointRaceOpponent opponent, long points) {
        PointRaceRank rank = new PointRaceRank();
        rank.setUid(opponent.getSnapshot().uid);
        rank.value = points;
        rank.owner = opponent.getSnapshot();
        rank.recordTime = System.currentTimeMillis();
        return rank;
    }


    public String getIndexName() {
        return getUid();
    }

    public String getIndexServerName() {
        return String.valueOf(owner.base.srvId);
    }
}
